package vn.edu.saigontech.ncms.service.impl;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;

import vn.edu.saigontech.ncms.model.info.InternalReceipt;
import vn.edu.saigontech.ncms.service.InternalReceiptService;
import vn.edu.saigontech.ncms.util.Checker;

@SuppressWarnings("unchecked")
public class InternalReceiptServiceImpl extends HibernateGenericService<InternalReceipt, Long> implements InternalReceiptService {

	public Collection<InternalReceipt> find(String name, String number,
			Date date, Date fromDate, Date toDate, Long cashierId,
			String comment) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<InternalReceipt> findByDateAsc(Date fromDate, Date toDate) {
		Criteria criteria = this.createCriteria();
		if(!Checker.isNull(fromDate)) {
			criteria.add(Restrictions.ge("date", fromDate));
		}
		if(!Checker.isNull(toDate)) {
			criteria.add(Restrictions.le("date", toDate));
		}
		criteria.addOrder(Order.asc("id"));
		return criteria.list();
	}
}